package org.openspml.providers.one_c;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.Map;

import org.openspml.message.SpmlResponse;
import org.openspml.util.SpmlException;

/**
 * @author <A href="mailto:abashev at gmail dot com">Alexey Abashev</A>
 * @version $Id$
 */
public class SpmlAssert {
	public static void assertResultSuccess(String message, SpmlResponse response) throws SpmlException {
		assertNotNull("Response can't be null", response);
		
		String result = response.getResult();
		
		assertEquals(message, SpmlResponse.RESULT_SUCCESS, result);
	}

	public static void assertResultFailure(String message, SpmlResponse response) throws SpmlException {
		assertNotNull("Response can't be null", response);

		String result = response.getResult();
		
		assertEquals(message, SpmlResponse.RESULT_FAILURE, result);

		String errorMessage = response.getErrorMessage();

		assertNotNull("Error message can't be null", errorMessage);
		assertTrue("Error message can't be empty", errorMessage.trim().length() > 0);
	}
	
	public static void assertErrorNoSuchId(String message, SpmlResponse response) throws SpmlException {
		String result = response.getResult();
		
		assertEquals(message, SpmlResponse.RESULT_FAILURE, result);
		assertEquals(message, SpmlResponse.ERROR_NO_SUCH_IDENTIFIER, response.getError());
	}
	
	public static void assertMapEquals(String message, Map expected, Map actual) {
		// TODO		
	}
	
	public static void assertMapSame(String message, Map expected, Map actual) {
		// TODO		
	}
}
